from fetchemApp.models import *
import zipfile
import os

def zipper(A):
    subs = A.submission_set.all()
    zname = A.SubjectLine + '.zip'
    zf = zipfile.ZipFile(zname, mode='w')
    try:
        for s in subs:
            print s
            f = s.FileName
            print 'Adding...' + f
            zf.write(f, os.path.basename(f), zipfile.ZIP_DEFLATED)
    finally:
        print 'Closing file...'
        zf.close()
        print 'Done!'